
package swb.api.com.repository.dto;

import lombok.Data;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 用户信息实体类
 * 映射数据库中的user_info表，存储用户的基本信息
 */
@Data
@Entity
@Table(name = "user_info", indexes = {
        @Index(name = "idx_openid", columnList = "openid"),
        @Index(name = "idx_unionid", columnList = "unionid"),
        @Index(name = "idx_mobile", columnList = "mobile"),
        @Index(name = "idx_status", columnList = "status"),
        @Index(name = "idx_created_at", columnList = "created_time")
})
public class UserInfo {

    /**
     * 用户ID，主键，自增
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 用户openid，唯一标识
     */
    @Column(unique = true)
    private String openid;

    /**
     * 用户unionid，唯一标识
     */
    @Column(unique = true)
    private String unionid;

    /**
     * 用户昵称
     */
    private String nickname;

    /**
     * 用户头像URL
     */
    @Column(name = "avatar_url")
    private String avatarUrl;

    /**
     * 用户性别
     * 1表示男性，2表示女性，0表示未知
     */
    private Integer gender;

    /**
     * 用户手机号，唯一
     */
    @Column(unique = true)
    private String mobile;

    /**
     * 用户余额，默认为0
     */
    private BigDecimal balance = BigDecimal.ZERO;

    /**
     * 冻结余额，默认为0
     */
    @Column(name = "frozen_balance")
    private BigDecimal frozenBalance = BigDecimal.ZERO;

    /**
     * 最低提现限额，默认为0
     */
    @Column(name = "min_withdraw")
    private BigDecimal minWithdraw = BigDecimal.ZERO;

    /**
     * 用户邮箱
     */
    private String email;

    /**
     * 用户状态，1表示正常状态
     */
    private Integer status = 1;

    /**
     * 创建时间
     */
    @Column(name = "created_time")
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;


}